// pages/messageList/messageList.js
import api from '../../utils/api.js'
const app = getApp()
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		msgData: [],
		page: 1,
	},
	getData() {
		wx.showLoading({
			title: '数据加载中'
		})
		var that = this;
		let apis = api.api;
		let url = apis.host + "message/list";
		let data = {
			page: that.data.page + '',
			/* 是	string	当前页码 */
			size: '10',
			/* 是	string	每页数量 */
			type: '0',
			/* 是	string	当前用户登录类型 */
		}
		apis.request(url, data, 'POST').then(function(res) {
			let data = res;
			if (res.code == 200) {
				// data.map((value, index) => {
				// 	mes.push(value)
				// })
				that.setData({
					msgData: [...that.data.msgData, ...res.data]
				})
				wx.hideLoading()
			}
		}).catch(function(res) {
		})
	},
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {
		var that = this;
		that.getData()
	},
	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {
		var that = this;
		that.setData({
			page: that.data.page + 1
		})
		that.getData()
	},
})
